package com.lagou.consumer.controller;

import com.lagou.service.BHelloService;
import com.lagou.service.CHelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/consumer")
public class IndexController {

    @Reference
    private BHelloService bHelloService;
    @Reference
    private CHelloService cHelloService;

    // 调用dubbo-B服务
    @RequestMapping("/b")
    public String printIpToB(HttpServletRequest request) {
        RpcContext.getContext().setRequest(request);
        bHelloService.printIpB();
        return "调用成功";
    }

    // 调用dubbo-C服务
    @RequestMapping("/c")
    public String printIpToC(HttpServletRequest request) {
        RpcContext.getContext().setRequest(request);
        cHelloService.printIpC();
        return "调用成功";
    }


}
